package com.ahcfl.dao;

import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.annotations.Param;

public class UserSqlProvider {

    public String findUserByPageAndUsername(    @Param("start") int start,
                                                @Param("pageSize") int pageSize,
                                                @Param("name") String name){
        StringBuffer sb = new StringBuffer();
        sb.append("select * from user ");
        if(StringUtils.isNotEmpty(name)){
            sb.append("where name like concat('%',#{name},'%') ");
        }

        sb.append(" limit #{start},#{pageSize}");

        return sb.toString();
    }

    public String findTotalUserByPageAndUsername(@Param("name") String name){
        StringBuffer sb = new StringBuffer();
        sb.append("select count(*) from user ");
        if(StringUtils.isNotEmpty(name)){
            sb.append("where name like concat('%',#{name},'%') ");
        }

        return sb.toString();
    }
}
